package com.atguigu.gmall.weball.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.feign.product.CategoryFeignCilent;
import com.atguigu.gmall.weball.vo.CategoryTreeVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class IndexController {

    @Autowired
    CategoryFeignCilent categoryFeignCilent;

    @GetMapping({"/","/index.html"})
    public String index(Model model){
        //发起远程调用
        Result<List<CategoryTreeVo>> categoryTree = categoryFeignCilent.getCategoryTree();
        // 得到商品服务提供数据
        List<CategoryTreeVo> categoryVos = categoryTree.getData();
        model.addAttribute("list",categoryVos);
        return "index/index";
    }
}
